package cn.tinlan.shopcoin.app.home.adapter;

import android.content.Context;
import android.graphics.Paint;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import cn.tinlan.shopcoin.R;
import cn.tinlan.shopcoin.app.discover.classify.model.GoodsCategoryDetailModel;
import cn.tinlan.shopcoin.widget.category.Constants;


/**
 * Created by Mortimer on 2018/11/20. 19:01
 * 佛祖🙏，永无bug。
 */
public class ShopListAdapter extends BaseQuickAdapter<GoodsCategoryDetailModel,BaseViewHolder> {

    private Context context;

    public ShopListAdapter(Context context, int layoutResId, @Nullable List<GoodsCategoryDetailModel> data) {
        super(layoutResId, data);
        this.context = context;
//        Log.i("test>>>>","zoule11111");
    }

    @Override
    protected void convert(BaseViewHolder helper, GoodsCategoryDetailModel item) {
//设置logo
//        Log.i("test>>>>","zoule11112121");
        ImageView ivLogo = helper.getView(R.id.item_img);
        Glide.with(context).load(Constants.IMGURL+item.getThumb()).into(ivLogo);
        //设置描述
        helper.setText(R.id.item_descri, item.getName());
        //设置最新价
        helper.setText(R.id.item_newprice,"￥"+item.getPrice());

        TextView oldPrice = helper.getView(R.id.item_oldprice);
        oldPrice.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);
        helper.setText(R.id.item_oldprice,"￥"+item.getMarket_price());

        helper.setText(R.id.item_sold_num, "已售"+item.getSales()+"件");
        //设置现价
//        List<ShopGroupInfoModel> groupInfos = item.getGroupInfos();

//        if(!groupInfos.isEmpty()){
//            ShopGroupInfoModel groupInfo = groupInfos.get(0);
//            helper.setText(R.id.tv_price, "¥" + groupInfo.getCurrentPrice());
//            //设置原价
//            helper.setText(R.id.tv_original_price, "门市价:¥" + groupInfo.getOriginalPrice());
//            //已售
//            helper.setText(R.id.tv_shop_sold, "已售" + groupInfo.getSoldNum());
//        }
    }


}
